home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gsfuncv.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  2.7 KB  |  92 lines

  1. /* Copyright (C) 2000 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gsfuncv.c,v 1.2 2000/09/19 19:00:28 lpd Exp $ */
  20. /* "Vanilla" Function support */
  21. #include "gx.h"
  22. #include "gserrors.h"
  23. #include "gsfuncv.h"
  24. #include "gsparam.h"
  25. #include "gxfunc.h"
  26.  
  27. /* GC descriptor */
  28. private_st_function_Va();
  29.  
  30. /*
  31.  * Test whether a Vanilla function is monotonic.  (This information is
  32.  * provided at function definition time.)
  33.  */
  34. private int
  35. fn_Va_is_monotonic(const gs_function_t * pfn_common,
  36.            const float *lower, const float *upper,
  37.            gs_function_effort_t effort)
  38. {
  39.     const gs_function_Va_t *const pfn =
  40.     (const gs_function_Va_t *)pfn_common;
  41.  
  42.     return pfn->params.is_monotonic;
  43. }
  44.  
  45. /* Free the parameters of a Vanilla function. */
  46. void
  47. gs_function_Va_free_params(gs_function_Va_params_t * params,
  48.                gs_memory_t * mem)
  49. {
  50.     gs_free_object(mem, params->eval_data, "eval_data");
  51.     fn_common_free_params((gs_function_params_t *) params, mem);
  52. }
  53.  
  54. /* Allocate and initialize a Vanilla function. */
  55. int
  56. gs_function_Va_init(gs_function_t ** ppfn,
  57.             const gs_function_Va_params_t * params,
  58.             gs_memory_t * mem)
  59. {
  60.     static const gs_function_head_t function_Va_head = {
  61.     function_type_Vanilla,
  62.     {
  63.         NULL,            /* filled in from params */
  64.         (fn_is_monotonic_proc_t) fn_Va_is_monotonic,
  65.         gs_function_get_info_default,
  66.         fn_common_get_params,    /****** WHAT TO DO ABOUT THIS? ******/
  67.         (fn_free_params_proc_t) gs_function_Va_free_params,
  68.         fn_common_free
  69.     }
  70.     };
  71.     int code;
  72.  
  73.     *ppfn = 0;            /* in case of error */
  74.     code = fn_check_mnDR((const gs_function_params_t *)params, 1, params->n);
  75.     if (code < 0)
  76.     return code;
  77.     {
  78.     gs_function_Va_t *pfn =
  79.         gs_alloc_struct(mem, gs_function_Va_t, &st_function_Va,
  80.                 "gs_function_Va_init");
  81.  
  82.     if (pfn == 0)
  83.         return_error(gs_error_VMerror);
  84.     pfn->params = *params;
  85.     pfn->head = function_Va_head;
  86.     pfn->head.procs.evaluate = params->eval_proc;
  87.     pfn->head.is_monotonic = params->is_monotonic;
  88.     *ppfn = (gs_function_t *) pfn;
  89.     }
  90.     return 0;
  91. }
  92.